package com.bizark.rpc.api.exception;

/**
 * Created by tangshijun on 2017/3/20.
 */
public class RpcException extends Exception{

    private String errorCode;
    private String errorMessage;

    private RpcError rpcError;

    public RpcException() {

    }

    public RpcException(RpcError error) {
        this.errorCode = error.errCode();
        this.errorMessage = error.errMessage();
        this.rpcError = error;
    }

    public RpcException(RpcError error, String msg) {
        this.errorCode = error.errCode();
        this.errorMessage = msg;
        this.rpcError = error;
    }

    public RpcException(String errCode, String msg) {
        this.errorCode = errCode;
        this.errorMessage = msg;
    }

    @Override
    public synchronized Exception fillInStackTrace() {
        return null;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    @Override
    public String getMessage() {
        return getErrorMessage();
    }

    public RpcError getTradeError() {
        return rpcError;
    }

}
